//
//  CurrentInforBottonView.m
//  YiXiProject
//
//  Created by xingshuai on 2019/8/4.
//  Copyright © 2019 iMac. All rights reserved.
//

#import "CurrentInforBottonView.h"

@implementation CurrentInforBottonView

-(UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"Mary";
        _nameLabel.font = HeiTiFont(30);
    }
    return _nameLabel;
}

-(UILabel *)jobLabel
{
    if(!_jobLabel)
    {
        _jobLabel = [[UILabel alloc] init];
        _jobLabel.text = @"Teacher";
        _jobLabel.font = Font(25);
    }
    return _jobLabel;
}

-(UILabel *)inforLabel
{
    if(!_inforLabel)
    {
        _inforLabel = [[UILabel alloc] init];
        _inforLabel.text = @"nice to miss you !";
        _inforLabel.font = Font(20);
        _inforLabel.numberOfLines = 0;
    }
    return _inforLabel;
}


-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self addSubview:self.nameLabel];
        [self addSubview:self.jobLabel];
        [self addSubview:self.inforLabel];
        
        [self creatBtn];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _nameLabel.sd_layout.leftSpaceToView(self, 20).topSpaceToView(self, 20).rightSpaceToView(self, 110).heightIs(40);
    
    _jobLabel.sd_layout.leftSpaceToView(self, 20).topSpaceToView(_nameLabel, 5).rightSpaceToView(self, 110).heightIs(30);
    
    _inforLabel.sd_layout.leftSpaceToView(self, 20).topSpaceToView(_jobLabel, 30).rightSpaceToView(self, 15).heightIs(50);
}

-(void)creatBtn
{
    NSArray *arr = @[@"inforNoLike",@"inforSC",@"inforLike"];
    
    for (int i = 0; i < 3; i ++)
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setBackgroundColor:ColorAlphe(245, 245, 245, 1)];
        [button setBackgroundImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];
        button.tag = 100 + i;
        
        button.layer.borderWidth = 1;
        button.layer.borderColor = ColorAlphe(240, 240, 240, 1).CGColor;
        
        [button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
        if(i == 0)
        {
            button.frame = CGRectMake(SCREEN_WIDTH/3*i+SCREEN_WIDTH/6, SCREEN_HEIGHT/2/3*2-20, 80, 80);
            button.layer.cornerRadius = 40;
            button.layer.masksToBounds = YES;
            
            
        }
        else if (i == 1)
        {
            button.frame = CGRectMake(SCREEN_WIDTH/2-25, SCREEN_HEIGHT/2/3*2-5, 50, 50);
            button.layer.cornerRadius = 25;
            button.layer.masksToBounds = YES;
        }
        else
        {
            button.frame = CGRectMake(SCREEN_WIDTH-SCREEN_WIDTH/6-80, SCREEN_HEIGHT/2/3*2-20, 80, 80);
            button.layer.cornerRadius = 40;
            button.layer.masksToBounds = YES;
        }
        
    }
}


-(void)clickBtn:(UIButton *)butt
{
    if([_delegate respondsToSelector:@selector(clickInforBtnTagNum:)])
    {
        [_delegate clickInforBtnTagNum:butt.tag];
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
